﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HRM.DAL.DAO;
using HRM.DAL.Gateway;
using HRM.DAL.Report;

namespace HRM.BLL
{
    public class PunishmentManager
    {
        PunishmentGateway gateway=new PunishmentGateway();
        public bool ApplyPunishment(Punishment punishment)
        {
            EmployeeManager employeeManager=new EmployeeManager();
            int empId = employeeManager.GetEmployeeID(punishment.Employee.EmpCode);
           // int punishedByEmpId = employeeManager.GetEmployeeID(punishment.PunishedBy.EmpCode);
            if(gateway.IsAlreadyPunished(empId))
            {
                return false;
            }
            else
            {
                return gateway.ApplyPunishment(punishment, empId);
            }
            
        }
        public List<ViewAllPunisedmentEmployee> GetAllPunishedEmployee()
        {
            return gateway.GetAllPunishedEmployee();
        }

        public List<ViewAllPunisedmentEmployee> GetAllPunishedEmployee(PunishmentType type)
        {
            return gateway.GetAllPunishedEmployee(type);
        }

        public List<ViewAllPunisedmentEmployee> GetAllPunishedEmployee(Code code)
        {
            return gateway.GetAllPunishedEmployee(code);
        }

        public bool EditPunishedEmployee(Punishment punishment)
        {
            EmployeeManager employeeManager = new EmployeeManager();
            int empId = employeeManager.GetEmployeeID(punishment.Employee.EmpCode);
            return gateway.EditPunishedEmployee(punishment,empId);
        }

        public bool ReleaseFromPunishment(Punishment punishment)
        {
            return gateway.ReleaseFromPunishment(punishment);
        }

        public string DeletePunish(int Id)
        {
            return gateway.DeletePunish(Id);
        }
    }
}